﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3
{
    class EnumExample1
    {
        static void _Main()
        {
            BorderSide topSide = BorderSide.Top;
            bool isTop = (topSide == BorderSide.Top); //true
            Console.WriteLine(isTop);

            //枚举类型转换
            int i = (int)BorderSide.Left;
            BorderSide side = (BorderSide)i;
            bool leftOrRight = (int)side <= 2;

            //两个枚举类型之间的转换是通过对应的数值进行的
            HorizontalAlignment h = (HorizontalAlignment)BorderSide.Right;
            //same as
            HorizontalAlignment h1 = (HorizontalAlignment)(int)BorderSide.Right;
        }
    }   
    public enum BorderSide { Left,Right,Top,Bottom}

    //指定其他的整数类型代替默认类型
    public enum BorderSide1 :byte{ Left, Right, Top, Bottom }

    //显式指定每一个枚举成员对应的值
    public enum BorderSide2 : byte { Left=1, Right=2, Top=10, Bottom=11 }

    //在最后一个显式指定的基础上递增
    public enum BorderSide3 : byte { Left = 1, Right, Top = 10, Bottom }

    //枚举类型转换
    public enum HorizontalAlignment
    { 
        Left = BorderSide.Left,
        Right = BorderSide.Right,
        Center
    }
}
